$(function(){
	var sa = $.query.get('sel');
	if(sa.indexOf("g501")!=-1||sa.indexOf("g7")!=-1){
		$(".d_cardid").css("display","");
	}
	if(sa.indexOf("g502")!=-1||sa.indexOf("g503")!=-1||sa.indexOf("g6")!=-1){
		$(".d_cardid").css("display","");
		$(".d_phone").css("display","");
	}

	if(sa.indexOf("g14")!=-1){
		$(".d_gid").css("display","");
	}

})


function reportNext(){
	var sel = checkval2();
	var token = $.query.get("token");
	window.location = "reportParam.html?token="+token+"&sel="+sel;
}


 
function reportSubmit(){

	$('#myModal').on('hidden.bs.modal', function (e) {
		WeixinJSBridge.call('closeWindow');
	})
    $(".btn-block").html("请稍等.....");

	var token = $.query.get('token');
	var sel = $.query.get('sel');
	var name = $("#name").val();
	var cid = $("#cid").val();
    var phone = $("#phone").val();
	var cardid = $("#cardid").val();
	var gid = $("#gid").val();
	var email = $("#email").val();

 //   获取所有为显示状态的input 的值并判断
    for(var i=0; i<$(".c_hid:visible").length; i++){
     if($(".c_hid:visible>input")[i].value==""){
         alert("请填写参数");
         return false;
     }
    }


	//window.location = "/down/test?name="+name+"&cid="+cid+"&cardid="+cardid+"&gid="+gid+"&token="+token+"&interfaces="+sel+"&email="+email;
	//$('#myModal').modal('toggle');

    $.ajax({
		url:"/down/filePdf?name="+name+"&cid="+cid+"&cardid="+cardid+"&gid="+gid+"&token="+token+"&interfaces="+sel+"&email="+email,
		type:"get",
		success:function(str){
            if(str=="no"){
                $(".modal-body").html("发送失败,请检查参数是否正确!!");
                $('#myModal').modal('toggle');

            }else{
                $(".modal-body").html("发送成功,请到邮箱查阅附件!!");
                $('#myModal').modal('toggle');
            }


		}
    });

}

 
function checkval2() {
	var arr = "";
	var obj = $("input[name='p_interface']");
	for (var i = 0; i < obj.length; i++) {
		if (obj[i].checked) {
			arr = arr + obj[i].value + ","; //如果选中，将value添加到变量s中
		}
	}
	arr = arr.substring(0, arr.length - 1).split(",");
	return arr;
}